package com.example.util;

public class UserContext {
    private  static final ThreadLocal<Long> currentUser = new ThreadLocal<>();
    //获取当前用户
    public static Long getCurrentUserId() {
        return currentUser.get();
    }
    //设置当前用户
    public static void setCurrentUserId(Long userId) {
        currentUser.set(userId);
    }

    //清空当前用户
    public static void clear() {
        currentUser.remove();
    }
}
